package com.cxs.studentManagerSystem.base;

import com.alibaba.fastjson.JSONObject;

/**
 * @Project: wanju-web
 * @Author: cxs2014501@163.com
 * @Create: 2022/9/8 9:51
 * @Description:
 **/
public class BaseResult<T> {
    private Integer code;
    private String msg;
    private T data;

    public BaseResult() {
    }

    public BaseResult(Integer code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static BaseResult ok(){
        return new BaseResult(200, "操作成功", new JSONObject());
    }

    public static BaseResult ok(Object data){
        return new BaseResult(200, "操作成功", data);
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    @Override
    public String toString() {
        return "BaseResult{" +
                "code=" + code +
                ", msg='" + msg + '\'' +
                ", data=" + data +
                '}';
    }
}
